$(function() {
	
	$("#left").load("../common/gover-left.html");
	var businessId = parseQueryString().businessId;
	var type = parseQueryString().type;
	var userType = parseQueryString().userType;
	var code = parseQueryString().code;
	var userId = sessionStorage.getItem("userId");
	var index = isEmpty(parseQueryString().index)?'input':parseQueryString().index;
	windowOpen('../up/face2faceWaiting.html?index='+index+'&code='+code+'&userId='+userId);
	$(".ystep1").loadStep({
		size: "small",
		color: "green",
		steps: [{
				title: "事项选择"
			},
			{
				title: "服务选择"
			},
			{
				title: "信息录入"
			},
			{
				title: "寄件选择"
			},
			{
				title: "取件选择"
			},
			{
				title: "提交成功"
			}
		]
	});
	$(".ystep1").setStep(2);
	my_vue = new Vue({
		el: '#vue_info',
		data: {
			index:index,
			isF:false,
			titleName:sessionStorage.getItem('titleName')
		},
		methods: {
			//获取面对面连接状态
			getQueueStatus: function() {
				if(index=='consult'){
					userId = "10000";
				}
				$.ajax({
					url: face.getFaceState + '?t='+new Date().getMilliseconds(),
					data: {
						userId: userId
					},
					async: true,
					type: 'get',
					success: function(result) {
						var obj = toObj(result);
						if(obj.success) {
							if(obj.data.type==1){
								if(index=='input'){
									sessionStorage.setItem("isFace",1);
									window.location="selfHelpFormInput.html?businessId=" + businessId + "&type=" + type + "&code=" + code+ "&userType=" + userType;
								} else if(index=='file'){
									sessionStorage.setItem("isFace",1);
									window.location="selfHelpAttachment.html";
								} else if(index = "consult"){
									sessionStorage.setItem("isFace",1);
									my_vue.isF =true;
								}
							}else if(obj.data.type==0){
								window.setTimeout(function(){
									my_vue.getQueueStatus();
								},1500);
							}else if(obj.data.type==3){
								if(index=='input'){
									window.location="selfHelpFormInput.html?businessId=" + businessId + "&type=" + type + "&code=" + code+ "&userType=" + userType+'?t='+new Date().getMilliseconds();
								} else if(index=='file'){
									window.location="selfHelpAttachment.html";
								} else if(index = "consult"){
									window.location="index.html";
								}
							}
							
						} else {
							showRedMsg("","坐席正忙,请稍后重试");
						}
					},
					error: function() {
						showRedMsg("","坐席正忙,请稍后重试");
					}
				});
			},
			//自助端退出排队
			clientExitQueue: function() {
				doMask();
				$.ajax({
					url: face.setFaceState+'?t='+new Date().getMilliseconds(),
					data: {
						userId: userId,
						type:3
					},
					async: true,
					type: 'post',
					success: function(result) {
						var obj = toObj(result);
						if(obj.success) {
							if(index!='consult'){
								window.location="selfHelpFormInput.html?businessId=" + businessId + "&type=" + type + "&code=" + code+ "&userType=" + userType;
							}else{
								window.location="index.html";
							}
						} else{
							unMask();
						}
					},
					error: function() {
						unMask();
					}
				});
			}
		},
		ready: function() {
			//初始化获得总页面数和列表数据
			this.getQueueStatus();
		}
	});
});